class AnimationBase:
	def __init__(self, frames, hitboxFrames):
		self.frames = frames
		if hitboxFrames == None:
			self.hitboxFrames = [ [] for frame in frames ]
		else:
			self.hitboxFrames = hitboxFrames
		self.n = 0			  	#Frame index
		self.ended = False		#Are there frames left?
		self.canExit = False	#Can we leave the animation (cancel out)

	def setHitboxFrames(self, hitboxFrames):
		if len(hitboxFrames) == len(self.frames):
			self.hitboxFrames = hitboxFrames

	def update(self):
		self.n += 1
		if(self.n >= len(self.frames)):
			self.ended = True
			self.canExit = True
	
	def start(self):
		self.n = 0
		self.ended = False
		self.canExit = False

	def getFrame(self):
		return self.frames[min(self.n, len(self.frames)-1)]

	def getHitboxFrame(self):
		return self.hitboxFrames[min(self.n, len(self.frames)-1)]

class SimpleAnimation(AnimationBase):
	def __init__(self, frames, hitboxFrames):
		AnimationBase.__init__(self, frames, hitboxFrames)

class LoopingAnimation(AnimationBase):
	def __init__(self, frames, hitboxFrames):
		AnimationBase.__init__(self, frames, hitboxFrames)
		self.canExit = True

	def update(self):
		self.n += 1
		if(self.n >= len(self.frames)):
			self.n = 0
			
	def start(self):
		self.n = 0
		self.canExit = True
		
class ParryAnimation(AnimationBase):
	def __init__(self, frames, hitboxFrames):
		AnimationBase.__init__(self, frames, hitboxFrames)
		self.canExit = True

	def start(self):
		self.n = 0
		self.ended = False
		self.canExit = True